package com.hpu.servlet;


import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.hpu.entity.Menu;
import com.hpu.service.MenuService;
import com.sun.org.apache.bcel.internal.generic.POP;

public class DishServlet extends HttpServlet {

	
	private static final long serialVersionUID = 1L;

	@Override
	protected void service(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		
		String s= request.getParameter("s");
		if(s == null || "".equals(s)) {
			recommend(request,response);
			
		}else if ("onsale".equals(s)) {
			onsale(request,response);
		}else if ("pop".equals(s)) {
			popu(request,response);
		}else if ( "esp".equals(s)) {
			esp(request,response);
		}else if ("cold".equals(s)) {
			cold(request,response);
		}else if ("hot".equals(s)) {
			hot(request,response);
		}else if ("mainfood".equals(s)) {
			mainfood(request,response);
		}else if ("ganguo".equals(s)) {
			ganguo(request,response);
		}else if ("fish".equals(s)) {
			fish(request,response );
		}else if ("jiu".equals(s)) {
			jiu(request,response);
		}else if ("sweet".equals(s)) {
			sweet(request,response);
		}
		
		
	}
	private void sweet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String category="7";
		MenuService menuService=new MenuService();
		List<Menu>  dishlist=menuService.findAllRecommendDish(category);
		request.setAttribute("dishlist",dishlist);
		request.getRequestDispatcher("/WEB-INF/views/dish.jsp").forward(request, response);			
	}
	private void jiu(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String category="6";
		MenuService menuService=new MenuService();
		List<Menu>  dishlist=menuService.findAllRecommendDish(category);
		request.setAttribute("dishlist",dishlist);
		request.getRequestDispatcher("/WEB-INF/views/dish.jsp").forward(request, response);	
	}
	private void fish(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String category="4";
		MenuService menuService=new MenuService();
		List<Menu>  dishlist=menuService.findAllRecommendDish(category);
		request.setAttribute("dishlist",dishlist);
		request.getRequestDispatcher("/WEB-INF/views/dish.jsp").forward(request, response);	
	}
	private void ganguo(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String category="3";
		MenuService menuService=new MenuService();
		List<Menu>  dishlist=menuService.findAllRecommendDish(category);
		request.setAttribute("dishlist",dishlist);
		request.getRequestDispatcher("/WEB-INF/views/dish.jsp").forward(request, response);	
	}
	private void mainfood(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		String category="5";
		MenuService menuService=new MenuService();
		List<Menu>  dishlist=menuService.findAllRecommendDish(category);
		request.setAttribute("dishlist",dishlist);
		request.getRequestDispatcher("/WEB-INF/views/dish.jsp").forward(request, response);	
	}
	private void hot(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String category="2";
		MenuService menuService=new MenuService();
		List<Menu>  dishlist=menuService.findAllRecommendDish(category);
		request.setAttribute("dishlist",dishlist);
		request.getRequestDispatcher("/WEB-INF/views/dish.jsp").forward(request, response);	
	}
	private void cold(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String category="1";
		MenuService menuService=new MenuService();
		List<Menu>  dishlist=menuService.findAllRecommendDish(category);
		request.setAttribute("dishlist",dishlist);
		request.getRequestDispatcher("/WEB-INF/views/dish.jsp").forward(request, response);			
	}
	private void esp(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String category="1";
		MenuService menuService=new MenuService();
		List<Menu>  dishlist=menuService.findAllRecommendDish(category);
		request.setAttribute("dishlist",dishlist);
		request.getRequestDispatcher("/WEB-INF/views/dish.jsp").forward(request, response);	
	}
	private void popu(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String category="1";
		MenuService menuService=new MenuService();
		List<Menu>  dishlist=menuService.findAllRecommendDish(category);
		request.setAttribute("dishlist",dishlist);
		request.getRequestDispatcher("/WEB-INF/views/dish.jsp").forward(request, response);	
	}
	private void onsale(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String category="5";
		MenuService menuService=new MenuService();
		List<Menu>  dishlist=menuService.findAllRecommendDish(category);
		request.setAttribute("dishlist",dishlist);
		request.getRequestDispatcher("/WEB-INF/views/dish.jsp").forward(request, response);	
		
		
	}
	private void recommend(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		String category="1";
		MenuService menuService=new MenuService();
		List<Menu>  dishlist=menuService.findAllRecommendDish(category);
		request.setAttribute("dishlist",dishlist);
		request.getRequestDispatcher("/WEB-INF/views/dish.jsp").forward(request, response);		
	}
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
}
